package com.datastructures2.字符串;

import java.util.HashSet;
import java.util.Set;

/**
 * @author MaoLin Wang
 * @date 2020/10/5 9:46 上午
 */
public class 最长回文串 {

    public static int test(String str){
        if (str==null || str.length()==0){
            return 0;
        }
        char[] chars = str.toCharArray();
        Set<Character> set=new HashSet<>();
        int count=0;
        for (char c : chars) {
            if (set.contains(c)){
                count++;
                set.remove(c);
            }else {
                set.add(c);
            }
        }
        return set.isEmpty()?count*2:count*2+1;
    }

    public static void main(String[] args) {
        System.out.println(        test("abccccdd"));
    }
}
